package userConsole.service;

import org.json.JSONException;
import org.json.JSONObject;
import userConsole.jdbc.BaseJDBC;
import userConsole.jdbc.UserJDBC;

import java.sql.SQLException;

/**
 * @author Godv
 * @version 1.0
 */
public class DeleteByIdService {
    public JSONObject deleteById(String id) throws JSONException {
        JSONObject jsonObject = new JSONObject();
        try {
            new UserJDBC().deleteById(BaseJDBC.createConnection(), id);
            jsonObject.put("code", 200);
            jsonObject.put("msg", "删除用户成功");
        } catch (SQLException e) {
            e.printStackTrace();
            jsonObject.put("code", 306);
            jsonObject.put("msg", "系统繁忙，请稍候重试！");
        }
        return jsonObject;
    }
}
